﻿#region Using Directives

    using System;
    using System.Xml.Linq;
    using System.Linq;

    using Csla;

    using MarketPulse.BusinessLogic.Core;

#endregion

namespace MarketPulse.Reporting.Core
{
    /// <summary>
    /// This class represents a read only instance of a reporting Visit within the system.
    /// </summary>
    [Serializable]
    public class ReportingVisitInfo : MarketPulseReadOnlyBase<ReportingVisitInfo>
    {

        #region Constructors

            /// <summary>
            /// Default constructor is private in order to (try to) enforce construction
            /// only via the static factory methods provided.
            /// </summary>
            protected ReportingVisitInfo()
            {
            }

        #endregion

        #region Methods

            ///// <summary>
            ///// Method used to retrieve the Component Label value in the language specified
            ///// </summary>
            ///// <param name="languageCode">The language code for the language to retrieve the Component label in</param>
            ///// <returns>The component label</returns>
            //public string GetComponentLabel(string languageCode)
            //{
            //    return (from t in ComponentLabel.Elements("text")
            //            where t.Attribute("language").Value.Equals(languageCode)
            //            select t).FirstOrDefault().Value;
            //}


        #endregion

        #region Properties

            /// <summary>
            /// The ID for this Visit.
            /// </summary>
            public static PropertyInfo<Nullable<long>> VisitIDProperty = RegisterProperty<Nullable<long>>(p => p.ID);
            /// <summary>
            /// The ID for this Visit.
            /// </summary>
            public Nullable<long> ID
            {
                get { return GetProperty(VisitIDProperty); }
            }

            #region Association GUID Properties (Foreign Keys)

            /// <summary>
            /// The GUID of the associated branch.
            /// </summary>
            public static PropertyInfo<Nullable<Guid>> BranchGUIDProperty = RegisterProperty<Nullable<Guid>>(p => p.BranchGUID);
            /// <summary>
            /// The GUID of the associated branch.
            /// </summary>
            public Nullable<Guid> BranchGUID
            {
                get { return GetProperty(BranchGUIDProperty); }
            }

            /// <summary>
            /// The GUID of the associated round. 
            /// </summary>
            public static PropertyInfo<Nullable<Guid>> RoundGUIDProperty = RegisterProperty<Nullable<Guid>>(p => p.RoundGUID);
            /// <summary>
            /// The GUID of the associated round. 
            /// </summary>
            public Nullable<Guid> RoundGUID
            {
                get { return GetProperty(RoundGUIDProperty); }
            }

            /// <summary>
            /// The GUID of the associated user.
            /// </summary>
            public static PropertyInfo<Nullable<Guid>> UserGUIDProperty = RegisterProperty<Nullable<Guid>>(p => p.UserGUID);
            /// <summary>
            /// The GUID of the associated user.
            /// </summary>
            public Nullable<Guid> UserGUID
            {
                get { return GetProperty(UserGUIDProperty); }
            }

            /// <summary>
            /// The GUID of the associated component.
            /// </summary>
            public static PropertyInfo<Nullable<Guid>> ComponentGUIDProperty = RegisterProperty<Nullable<Guid>>(p => p.ComponentGUID);
            /// <summary>
            /// The GUID of the associated component.
            /// </summary>
            public Nullable<Guid> ComponentGUID
            {
                get { return GetProperty(ComponentGUIDProperty); }
            }

            /// <summary>
            /// The GUID of the associated country. 
            /// </summary>
            public static PropertyInfo<Nullable<Guid>> CountryGUIDProperty = RegisterProperty<Nullable<Guid>>(p => p.CountryGUID);
            /// <summary>
            /// The GUID of the associated country. 
            /// </summary>
            public Nullable<Guid> CountryGUID
            {
                get { return GetProperty(CountryGUIDProperty); }
            }

            /// <summary>
            /// The GUID of the associated client. 
            /// </summary>
            public static PropertyInfo<Nullable<Guid>> ClientGUIDProperty = RegisterProperty<Nullable<Guid>>(p => p.ClientGUID);
            /// <summary>
            /// The GUID of the associated client. 
            /// </summary>
            public Nullable<Guid> ClientGUID
            {
                get { return GetProperty(ClientGUIDProperty); }
            }

            /// <summary>
            /// The GUID of the associated Language. 
            /// </summary>
            public static PropertyInfo<Nullable<Guid>> LanguageGUIDProperty = RegisterProperty<Nullable<Guid>>(p => p.LanguageGUID);
            /// <summary>
            /// The GUID of the associated Language. 
            /// </summary>
            public Nullable<Guid> LanguageGUID
            {
                get { return GetProperty(LanguageGUIDProperty); }
            }

            /// <summary>
            /// The VersionID of this visit.
            /// </summary>
            public static PropertyInfo<Nullable<int>> VisitVersionIDProperty = RegisterProperty<Nullable<int>>(p => p.VersionID);
            /// <summary>
            /// The VersionID of this visit.
            /// </summary>
            public Nullable<int> VersionID
            {
                get { return GetProperty(VisitVersionIDProperty); }
            }

            #endregion

            /// <summary>
            /// A human readable label for this Visit.
            /// </summary>
            public static PropertyInfo<string> LabelProperty = RegisterProperty<string>(p => p.Label);
            /// <summary>
            /// A human readable label for this Visit.
            /// </summary>
            public string Label
            {
                get { return GetProperty(LabelProperty); }
            }

            /// <summary>
            /// Thee possible score available for this Visit.
            /// </summary>
            public static PropertyInfo<int> PossibleScoreProperty = RegisterProperty<int>(p => p.PossibleScore);
            /// <summary>
            /// Thee possible score available for this Visit.
            /// </summary>
            public int PossibleScore
            {
                get { return GetProperty(PossibleScoreProperty); }
            }

            /// <summary>
            /// Thee actual score available for this Visit.
            /// </summary>
            public static PropertyInfo<int> ActualScoreProperty = RegisterProperty<int>(p => p.ActualScore);
            /// <summary>
            /// Thee actual score available for this Visit.
            /// </summary>
            public int ActualScore
            {
                get { return GetProperty(ActualScoreProperty); }
            }

            /// <summary>
            /// A switch that defines whether this ReportingVisit is published.
            /// </summary>
            public static PropertyInfo<bool> PublishedProperty = RegisterProperty<bool>(p => p.Published);
            /// <summary>
            /// A switch that defines whether this ReportingVisit is published.
            /// </summary>
            public bool Published
            {
                get { return GetProperty(PublishedProperty); }
            }

            /// <summary>
            /// The actual date and time this visit ended
            /// </summary>
            public static PropertyInfo<SmartDate> TransferredDateTimeProperty = RegisterProperty<SmartDate>(p => p.TransferredDateTime);
            /// <summary>
            /// The actual date and time this visit ended
            /// </summary>
            public SmartDate TransferredDateTime
            {
                get { return GetProperty(TransferredDateTimeProperty); }
            }

            /// <summary>
            /// The label of the associated component.
            /// </summary>
            //public static PropertyInfo<XElement> ComponentLabelProperty = RegisterProperty<XElement>(p => p.ComponentLabel);
            public static PropertyInfo<string> ComponentLabelProperty = RegisterProperty<string>(p => p.ComponentLabel);
            /// <summary>
            /// The label of the associated component.
            /// </summary>
            public string ComponentLabel
            {
                get { return GetProperty(ComponentLabelProperty); }
            }

            #region Valid Date/Time

                /// <summary>
                /// The date and time after which the visit must occur
                /// </summary>
                public static PropertyInfo<SmartDate> ValidStartDateTimeProperty = RegisterProperty<SmartDate>(p => p.ValidStartDateTime);
                public SmartDate ValidStartDateTime
                {
                    get { return GetProperty(ValidStartDateTimeProperty); }
                }

                /// <summary>
                /// The date and time before which the visit must occur
                /// </summary>
                public static PropertyInfo<SmartDate> ValidEndDateTimeProperty = RegisterProperty<SmartDate>(p => p.ValidEndDateTime);
                public SmartDate ValidEndDateTime
                {
                    get { return GetProperty(ValidEndDateTimeProperty); }
                }

            #endregion

            #region Planned Date/Time

                /// <summary>
                /// The planned date for this visit to occur
                /// </summary>
                public static PropertyInfo<SmartDate> PlannedDateTimeProperty = RegisterProperty<SmartDate>(p => p.PlannedDateTime);
                public SmartDate PlannedDateTime
                {
                    get { return GetProperty(PlannedDateTimeProperty); }
                }

            #endregion

            #region Actual Date/Time

                /// <summary>
                /// The actual date and time this visit started
                /// </summary>
                public static PropertyInfo<SmartDate> ActualStartDateTimeProperty = RegisterProperty<SmartDate>(p => p.ActualStartDateTime);
                public SmartDate ActualStartDateTime
                {
                    get { return GetProperty(ActualStartDateTimeProperty); }
                }

                /// <summary>
                /// The actual date and time this visit ended
                /// </summary>
                public static PropertyInfo<SmartDate> ActualEndDateTimeProperty = RegisterProperty<SmartDate>(p => p.ActualEndDateTime);
                public SmartDate ActualEndDateTime
                {
                    get { return GetProperty(ActualEndDateTimeProperty); }
                }

            #endregion

            #region Associated/Child Objects

                /// <summary>
                /// Any related ReportingQuestions for this ReportingVisit.
                /// </summary>
                public static PropertyInfo<ReportingQuestionInfoList> ReportingQuestionsProperty = RegisterProperty<ReportingQuestionInfoList>(p => p.ReportingQuestions);
                public ReportingQuestionInfoList ReportingQuestions
                {
                    get { return GetProperty(ReportingQuestionsProperty); }
                }

                /// <summary>
                /// The EffectiveStartDateTime of the Round this Visit belongs to.
                /// </summary>
                public static PropertyInfo<SmartDate> EffectiveRoundStartDateTimeProperty = RegisterProperty<SmartDate>(p => p.RoundStartDateTime);
                public SmartDate RoundStartDateTime
                {
                    get { return GetProperty(EffectiveRoundStartDateTimeProperty); }
                }

                /// <summary>
                /// The EffectiveEndDateTime of the Round this Visit belongs to.
                /// </summary>
                public static PropertyInfo<SmartDate> EffectiveRoundEndDateTimeProperty = RegisterProperty<SmartDate>(p => p.RoundEndDateTime);
                public SmartDate RoundEndDateTime
                {
                    get { return GetProperty(EffectiveRoundEndDateTimeProperty); }
                }

            #endregion

        #endregion

    }
}
